package com.paireach.bw.application;

import android.app.Application;
import android.content.Context;
import android.os.Handler;

import com.blankj.utilcode.utils.SPUtils;
import com.blankj.utilcode.utils.Utils;
import com.paireach.bw.activity.MainActivity;
import com.paireach.bw.activity.VersionInfoActivity;
import com.paireach.bw.bean.LocationInfo;
import com.paireach.bw.http.MainRequest;
import com.paireach.bw.http.NetUrl;
import com.paireach.bw.utils.LocationService;
import com.paireach.bw.utils.LogUtil;
import com.tencent.bugly.Bugly;
import com.tencent.bugly.beta.Beta;
import com.zhy.http.okhttp.OkHttpUtils;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.concurrent.TimeUnit;

import cn.jpush.android.api.JPushInterface;
import okhttp3.OkHttpClient;

/**
 * Created by ${cqc} on 2017/2/3.
 */

public class MyApplication extends Application {
    public LocationService locationService;
    public LocationInfo locationInfo;
    private static SPUtils spUtils;
    private static Context context;

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        //volley创建请求队列
        MainRequest.getInstance().initRequestQueue(this);

        //OkHttpUtils
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .build();
        OkHttpUtils.initClient(okHttpClient);

        Bugly.init(getApplicationContext(), "852a0b0358", false);

        Utils.init(this);
        spUtils = new SPUtils("BW");

        //百度定位
        locationService = new LocationService(getApplicationContext());
        locationInfo = new LocationInfo();

        //Jpush
        JPushInterface.setDebugMode(false);
        JPushInterface.init(this);
    }

    public static SPUtils getSpUtils() {
        return spUtils;
    }

    public static Context getContext() {
        return context;
    }
}
